home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Info-Mac 4
/
Info_Mac IV CD-ROM (Pacific HiTech Inc.)(August 1994).iso
/
Development
/
General
/
DR1.#1 PPC C⁄C++ ƒ
/
C++ Runtime ƒ
/
Startup.c
< prev
Wrap
C/C++ Source or Header
|
1994-01-31
|
2KB
|
111 lines
/*
* Startup.c - Default init/startup/termination routines for Metrowerks C++ (PowerPC)
*
* Copyright © 1993 metrowerks inc. All Rights Reserved.
*
*/
#include <Quickdraw.h>
/* public data */
QDGlobals qd; /* define the Quickdraw globals here! */
char __exit_abort; /* TRUE => skip __exit_proc and destructors */
void (*__exit_proc)(void); /* called when program terminates but before destructors */
/* external references */
extern int main(int argc, char **argv);
extern void __destroy_global_chain(void);
/* prototypes */
void __sinit(void);
int __initialize(void);
void __start(void);
void __terminate(void);
/*
* __sinit - stub for static initialization of C++ objects
*
* The linker replaces the contents of this module with something of the form:
*
* mflr r0
* stw r0,8(sp)
* stwu sp,-64(sp)
* bl __sinit_<file1>_1
* bl __sinit_<file1>_2
* ...
* bl __sinit_<file2>_1
* bl __sinit_<file2>_2
* ...
* bl __sinit_<fileN>_1
* bl __sinit_<fileN>_2
* ...
* addi sp,sp,64
* lwz r0,8(sp)
* mtlr r0
* blr
*/
void __sinit(void)
{
}
/*
* __initialize - Default initialization routine for Metrowerks C++ (PowerPC)
*
* This routine should be specified as the PEF initialization routine in the container
* for any application or shared library. It ensures that all C++ static objects are
* properly initialized, and returns noErr to the Code Fragment Manager.
*
*/
int __initialize(void)
{
__sinit();
return(0); /* noErr */
}
/*
* __start - Default startup routine for Metrowerks C++ (PowerPC)
*
* This routine should be specified as the PEF main routine in the container
* for any application. It sets up default values for 'argc' and 'argv' and
* calls 'main'.
*
*/
void __start(void)
{
char *argv = 0;
main(0, &argv);
}
/*
* __terminate - Default termination routine for Metrowerks C++ (PowerPC)
*
* This routine should be specified as the PEF termination routine in the container
* for any application or shared library. It calls the __exit_proc which handles
* atexit() routines and ensures that all C++ static objects are properly destroyed.
*
*/
void __terminate(void)
{
if (!__exit_abort) {
if (__exit_proc)
(*__exit_proc)();
__destroy_global_chain();
}
}